module common.imagehandler;

import mirdefine;
import common.imagearray;




public class ImageHandler
{
	public ImageArray m_xImageList[_MAX_IMAGE];
	
	public void LoadAllImage()
	{
		static immutable string szFileList[_MAX_IMAGE] = 
		[
            //~~~ ¹è°æÀÌ¹ÌÁö. ~~~
            "./Data/Tilesc.wil",
            "./Data/Tiles30c.wil",
            "./Data/Tiles5c.wil",
            "./Data/SmTilesc.wil",
            "./Data/Housesc.wil",
            "./Data/Cliffsc.wil",
            "./Data/Dungeonsc.wil",
            "./Data/Innersc.wil",
            "./Data/Furnituresc.wil",
            "./Data/Wallsc.wil",
            "./Data/SmObjectsc.wil",
            "./Data/Animationsc.wil",
            "./Data/Object1c.wil",
            "./Data/Object2c.wil",
            "",

            //~~~ wood ~~~
            "./Data/Wood/Tilesc.wil",
            "./Data/Wood/Tiles30c.wil",
            "./Data/Wood/Tiles5c.wil",
            "./Data/Wood/SmTilesc.wil",
            "./Data/Wood/Housesc.wil",
            "./Data/Wood/Cliffsc.wil",
            "./Data/Wood/Dungeonsc.wil",
            "./Data/Wood/Innersc.wil",
            "./Data/Wood/Furnituresc.wil",
            "./Data/Wood/Wallsc.wil",
            "./Data/Wood/SmObjectsc.wil",
            "./Data/Wood/Animationsc.wil",
            "./Data/Wood/Object1c.wil",
            "./Data/Wood/Object2c.wil",
            "",

            //~~~ sand ~~~
            "./Data/Sand/Tilesc.wil",
            "./Data/Sand/Tiles30c.wil",
            "./Data/Sand/Tiles5c.wil",
            "./Data/Sand/SmTilesc.wil",
            "./Data/Sand/Housesc.wil",
            "./Data/Sand/Cliffsc.wil",
            "./Data/Sand/Dungeonsc.wil",
            "./Data/Sand/Innersc.wil",
            "./Data/Sand/Furnituresc.wil",
            "./Data/Sand/Wallsc.wil",
            "./Data/Sand/SmObjectsc.wil",
            "./Data/Sand/Animationsc.wil",
            "./Data/Sand/Object1c.wil",
            "./Data/Sand/Object2c.wil",
            "",

            //~~~ snow ~~~
            "./Data/Snow/Tilesc.wil",
            "./Data/Snow/Tiles30c.wil",
            "./Data/Snow/Tiles5c.wil",
            "./Data/Snow/SmTilesc.wil",
            "./Data/Snow/Housesc.wil",
            "./Data/Snow/Cliffsc.wil",
            "./Data/Snow/Dungeonsc.wil",
            "./Data/Snow/Innersc.wil",
            "./Data/Snow/Furnituresc.wil",
            "./Data/Snow/Wallsc.wil",
            "./Data/Snow/SmObjectsc.wil",
            "./Data/Snow/Animationsc.wil",
            "./Data/Snow/Object1c.wil",
            "./Data/Snow/Object2c.wil",
            "",

            //~~~ forest ~~~
            "./Data/Forest/Tilesc.wil",
            "./Data/Forest/Tiles30c.wil",
            "./Data/Forest/Tiles5c.wil",
            "./Data/Forest/SmTilesc.wil",
            "./Data/Forest/Housesc.wil",
            "./Data/Forest/Cliffsc.wil",
            "./Data/Forest/Dungeonsc.wil",
            "./Data/Forest/Innersc.wil",
            "./Data/Forest/Furnituresc.wil",
            "./Data/Forest/Wallsc.wil",
            "./Data/Forest/SmObjectsc.wil",
            "./Data/Forest/Animationsc.wil",
            "./Data/Forest/Object1c.wil",
            "./Data/Forest/Object2c.wil",
            "",

            //~~~ ÀÎÅÍÆäÀÌ½ºÀÌ¹ÌÁö. ~~~
            "", 
            "",
            "",
            "",
            "./Data/Interface1c.wil",
            "./Data/GameInter.wil",

            //~~~ ³²ÀÚÀÌ¹ÌÁö. ~~~
            "./Data/M-Hum.wil",    
            "./Data/M-Hair.wil", 
            "./Data/M-Helmet1.wil", 
            "./Data/M-Helmet2.wil", 
            "./Data/M-Weapon1.wil",
            "./Data/M-Weapon2.wil",
            "./Data/M-Weapon3.wil",
            "./Data/M-Weapon4.wil",
            "./Data/M-Weapon5.wil",

            //~~~ ¿©ÀÚÀÌ¹ÌÁö. ~~~
            "./Data/WM-Hum.wil",
            "./Data/WM-Hair.wil",
            "./Data/WM-Helmet1.wil",
            "./Data/WM-Helmet2.wil",
            "./Data/WM-Weapon1.wil",
            "./Data/WM-Weapon2.wil",
            "./Data/WM-Weapon3.wil",
            "./Data/WM-Weapon4.wil",
            "./Data/WM-Weapon5.wil",

            //~~~ ¾ÆÀÌÅÛ ¹× ÀÎÅÍÆäÀÌ½º, ¸¶¹ý, ±âÅ¸ÀÌ¹ÌÁö. ~~~
            "./Data/Magic.wil",
            "./Data/MagicEx.wil",
            "./Data/Inventory.wil",
            "./Data/Equip.wil",
            "./Data/Ground.wil",
            "./Data/MIcon.wil",
            "./Data/Mmap.wil",
            "./Data/ProgUse.wil",
            "./Data/Horse.wil",

            //~~~ ¸ó½ºÅÍÀÌ¹ÌÁö. ~~~
            "./Data/Mon-1.wil",
            "./Data/Mon-2.wil",
            "./Data/Mon-3.wil",
            "./Data/Mon-4.wil",
            "./Data/Mon-5.wil",
            "./Data/Mon-6.wil",
            "./Data/Mon-7.wil",
            "./Data/Mon-8.wil",
            "./Data/Mon-9.wil",
            "./Data/Mon-10.wil",
            "./Data/Mon-11.wil",
            "./Data/Mon-12.wil",
            "./Data/Mon-13.wil",
            "./Data/Mon-14.wil",
            "./Data/Mon-15.wil",
            "./Data/Mon-16.wil",
            "./Data/Mon-17.wil",
            "./Data/Mon-18.wil",
            "./Data/Mon-19.wil",
            "./Data/Mon-20.wil",
            "./Data/Mon-54.wil",

            //~~~ ¸ó½ºÅÍ±×¸²ÀÚÀÌ¹ÌÁö. ~~~
            "./Data/MonS-1.wil",
            "./Data/MonS-2.wil",
            "./Data/MonS-3.wil",
            "./Data/MonS-4.wil",
            "./Data/MonS-5.wil",
            "./Data/MonS-6.wil",
            "./Data/MonS-7.wil",
            "./Data/MonS-8.wil",
            "./Data/MonS-9.wil",
            "./Data/MonS-10.wil",
            "./Data/MonS-11.wil",
            "./Data/MonS-12.wil",
            "./Data/MonS-13.wil",
            "./Data/MonS-14.wil",
            "./Data/MonS-15.wil",
            "./Data/MonS-16.wil",
            "./Data/MonS-17.wil",
            "./Data/MonS-18.wil",
            "./Data/MonS-19.wil",
            "./Data/MonS-20.wil",

            //~~~ NPC ÀÌ¹ÌÁö. ~~~
            "./Data/NPC.wil",
            "./Data/NPCface.wil",

            //~~~ ¸ó½ºÅÍ¸¶¹ý ÀÌ¹ÌÁö. ~~~
            "./Data/MonImg.wil",
            "./Data/MonMagic.wil",
            "./Data/MonMagicEx.wil",
            "./Data/MonMagicEx2.wil",
            "./Data/MonMagicEx3.wil",
            "./Data/MonMagicEx4.wil"
		];

		InitAllImage;
		
		for (int i = 0; i < _MAX_IMAGE; i++)
		{
            immutable flname = szFileList[i];
            if (flname == "") continue;

            m_xImageList[i].FileName = flname;
			m_xImageList[i].LibType = LibraryType.UseCache;
			m_xImageList[i].IVersion = InternationalVersion.English;
			m_xImageList[i].initialize;
		}
	}
	
	public void InitAllImage()
	{
		for (int i = 0; i < _MAX_IMAGE; i++)
			m_xImageList[i] = new ImageArray;
	}

	public void DeleteAllImage()
	{
		for (int i = 0; i < _MAX_IMAGE; i++)
		{
			m_xImageList[i].finalize;
			m_xImageList[i] = null;
		}
	}

    public void clearAllCache()
    {
        for (int i = 0; i < _MAX_IMAGE; i++)
        {
            m_xImageList[i].clearCache();
        }
    }
	
    public ImageArray opIndex(size_t index)
	{
		if (index >= 0 && index < _MAX_IMAGE)
			return m_xImageList[index];
		return null;
    }
}

